package com.smh.a04SetDemo1;

public class Student2 implements Comparable<Student2> {
    private String name;
    private int age;
    private double chinese;
    private double math;
    private double english;

    public Student2() {
    }


    public Student2(String name, int age, double chinese, double math, double english) {
        this.name = name;
        this.age = age;
        this.chinese = chinese;
        this.math = math;
        this.english = english;
    }

    /**
     * 获取
     *
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     *
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     *
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    /**
     * 获取
     *
     * @return chinese
     */
    public double getChinese() {
        return chinese;
    }

    /**
     * 设置
     *
     * @param chinese
     */
    public void setChinese(double chinese) {
        this.chinese = chinese;
    }

    /**
     * 获取
     *
     * @return math
     */
    public double getMath() {
        return math;
    }

    /**
     * 设置
     *
     * @param math
     */
    public void setMath(double math) {
        this.math = math;
    }

    /**
     * 获取
     *
     * @return english
     */
    public double getEnglish() {
        return english;
    }

    /**
     * 设置
     *
     * @param english
     */
    public void setEnglish(double english) {
        this.english = english;
    }

    public String toString() {
        return "Student2{name = " + name + ", age = " + age + ", chinese = " + chinese + ", math = " + math + ", english = " + english + ", total = " + (chinese + math + english) + "}";
    }

    @Override
    public int compareTo(Student2 o) {
        double sum1 = this.getChinese() + this.getMath() + this.getEnglish();
        double sum2 = o.getChinese() + o.getMath() + o.getEnglish();
        double temp = sum1 - sum2;
        int i = 0;
        if (temp > 0) {
            i = 1;
        } else if (temp < 0) {
            i = -1;
        } else {
            i = 0;
        }

        if (i == 0) {
            double temp2 = this.getChinese() - o.getChinese();
            if (temp2 > 0) {
                i = 1;
            } else if (temp2 < 0) {
                i = -1;
            } else {
                i = 0;
            }
        }

        if (i == 0) {
            double temp3 = this.getMath() - o.getMath();
            if (temp3 > 0) {
                i = 1;
            } else if (temp3 < 0) {
                i = -1;
            } else {
                i = 0;
            }
        }

        if (i == 0) {
            int temp4 = this.getAge() - o.getAge();
            i = temp4 == 0 ? 0 : temp4;
        }

        if (i == 0) {
            int temp5 = this.getName().length() - o.getName().length();
            i = temp5 == 0 ? 0 : temp5;
        }


        return i;
    }
}
